import { createRouter, createWebHashHistory } from 'vue-router'

import { permissionCheck } from './permission'

const staticRoutes = [
  {
    path: '/',
    component: () => import('@/views/Home.vue'),
    meta: { title: '首页' },
    redirect: '/welcome',
    children: [
      {
        path: '/welcome',
        meta: { title: '欢迎页' },
        component: () => import('@/views/Welcome.vue'),
      },
    ],
  },
  {
    path: '/login',
    component: () => import('@/views/Login.vue'),
  },

  // {
  // 	path: '/:pathMatch(.*)*',
  // 	component: () => import('@/views/404.vue')
  // }
]
const router = createRouter({
  history: createWebHashHistory(),
  // 静态路由，后面还会根据用户权限动态添加路由
  routes: staticRoutes,
})

// 检查切换前的权限
permissionCheck(router)

export default router
